﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;
using System.Windows.Forms;

namespace GraphsLab5
{
    public partial class Form1 : Form
    {

        enum Colors { Black, Red, Green, Blue }

        List<Point> points = new List<Point>();
        List<Color> colors = new List<Color>();
        List<List<int> > lines = new List<List<int> >();
        bool isDrawn = false;
        bool mouseDown = false;
        bool mouseMove = false;
        bool connect = false;
        bool mode = false;
        bool ctrl = false;
        bool deleteLine = false;
        int delete;
        int connectPoint;
        int pointMove;

        public Form1()
        {
            InitializeComponent();
        }

        
        private void dataGridView1_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            dataGridView1.Rows[e.Row.Index - 1].HeaderCell.Value = e.Row.Index.ToString();                
        }

        private void dataGridView1_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
        {
            int r = 0;
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                row.HeaderCell.Value = (r + 1).ToString();
                r++;
            }
        }

        private void Form1_SizeChanged(object sender, EventArgs e)
        { 
            int all = dataGridView1.Size.Width - dataGridView1.Rows[0].HeaderCell.Size.Width;
            int width = (int)(all / 4) - 2;
            for (int i = 0; i < 3; i++)
            {
                dataGridView1.Columns[i].Width = width;
            }
            dataGridView1.Columns[3].Width = all - width * 3 - 2;
            ClearButton.PerformClick();
            draw();
        }        

        private void EditButton_Click(object sender, EventArgs e)
        {
            mode = false;
            EditButton.Enabled = false;
            AddButton.Enabled = true;
        }

        private void AddButton_Click(object sender, EventArgs e)
        {
            mode = true;
            EditButton.Enabled = true;
            AddButton.Enabled = false;
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control) ctrl = true;
        }

        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ControlKey) ctrl = false;
        }

        private void HelpButton_Click(object sender, EventArgs e)
        {
            AboutBox1 a = new AboutBox1();
            a.Show();
        }      
           
    }
}
